import Vue from 'vue'
import App from '@/App.vue'
import router from '@/router'
import store from '@/store'
import Storage from 'vue-ls'

// 引入第三方UI组件
import Antd from 'ant-design-vue'
import 'core-js/stable'
import 'regenerator-runtime/runtime'

// 引入第三方样式
import 'ant-design-vue/dist/antd.less'

// 引入自定义配置项
import theme from '../public/config/theme.config'
import res from '@/api/response.code'
import {
  DEFAULT_COLOR,
  DEFAULT_THEME,
  DEFAULT_MULTI_PAGE
} from '@/store/mutation-types'

// 引入自定义组件
import '@/router/permission' // permission control
import '@/utils/filter' // base filter
import MicroRayComponents from '@/components/index'

// 引入自定义样式
import '@/style/global.less'

Vue.config.productionTip = false
Vue.prototype.$response = res

// 请求前置路径，方便编译打包时切换环境
Vue.prototype.$prePath = ''
Vue.prototype.$ucEnv = ''

Vue.use(Antd)
Vue.use(Storage, theme.storageOptions)
Vue.use(MicroRayComponents)

new Vue({
  router,
  store,
  mounted () {
    this.loadThemeConfig()
    this.$message.config({ top: '65px' })
  },
  methods: {
    /**
     * 加载样式配置
     */
    loadThemeConfig () {
      // store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
      store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, theme.navTheme))
      store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, theme.primaryColor))
      store.commit('SET_MULTI_PAGE', Vue.ls.get(DEFAULT_MULTI_PAGE, theme.multipage))
    }
  },
  render: h => h(App)
}).$mount('#app')
